home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / dev / c / flash-0.4.3.lha / flash-0.4.3 / Lib / character.cc < prev    next >
C/C++ Source or Header  |  1999-02-21  |  3KB  |  178 lines

  1. /////////////////////////////////////////////////////////////
  2. // Flash Plugin and Player
  3. // Copyright (C) 1998 Olivier Debon
  4. // 
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the GNU General Public License
  7. // as published by the Free Software Foundation; either version 2
  8. // of the License, or (at your option) any later version.
  9. // 
  10. // This program is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. // GNU General Public License for more details.
  14. // 
  15. // You should have received a copy of the GNU General Public License
  16. // along with this program; if not, write to the Free Software
  17. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  18. // 
  19. ///////////////////////////////////////////////////////////////
  20. //  Author : Olivier Debon  <odebon@club-internet.fr>
  21. //  
  22.  
  23. #include <stdio.h>
  24. #include "swf.h"
  25. #include "character.h"
  26.  
  27. static char *rcsid = "$Id: character.cc,v 1.6 1999/01/31 20:10:48 olivier Exp $";
  28.  
  29. ///// Character member definitions
  30.  
  31. Character::Character(ObjectType objectType, long tagid)
  32. {
  33.     type = objectType;
  34.     tagId = tagid;
  35. }
  36.  
  37. int
  38. Character::execute(GraphicDevice *gd, Matrix *matrix, Cxform *cxform)
  39. {
  40.     printf("Cannot be executed\n");
  41.     return 0;
  42. }
  43.  
  44. ActionRecord *
  45. Character::eventHandler(GraphicDevice *gd, FlashEvent *ev)
  46. {
  47.     fprintf(stderr,"Unable to handle event !!!\n");
  48.     return 0;
  49. }
  50.  
  51. int
  52. Character::hasEventHandler()
  53. {
  54.     return 0;
  55. }
  56.  
  57. void
  58. Character::getRegion(GraphicDevice *gd, Matrix *m, unsigned char id)
  59. {
  60.     return;
  61. }
  62.  
  63. long
  64. Character::getTagId()
  65. {
  66.     return tagId;
  67. }
  68.  
  69. void
  70. Character::reset()
  71. {
  72. }
  73.  
  74. ObjectType
  75. Character::getType()
  76. {
  77.     return type;
  78. }
  79.  
  80. char *
  81. Character::getTypeString()
  82. {
  83.     switch (type) {
  84.         case BitmapType:
  85.             return "Bitmap";
  86.         case FontType:
  87.             return "Font";
  88.         case ButtonType:
  89.             return "Button";
  90.         case SpriteType:
  91.             return "Sprite";
  92.         case ShapeType:
  93.             return "Shape";
  94.         case SoundType:
  95.             return "Sound";
  96.         case TextType:
  97.             return "Text";
  98.         default:
  99.             return "Unknown";
  100.     }
  101. }
  102.  
  103. ///// Dict methods definitions
  104.  
  105. Dict::Dict()
  106. {
  107.     head = 0;
  108. }
  109.  
  110. Dict::~Dict()
  111. {
  112.     struct sCharCell *cell,*del;
  113.     
  114.     for(cell = head; cell;)
  115.     {
  116.         del = cell;
  117.         cell = cell->next;
  118.         delete del;
  119.     }
  120. }
  121.  
  122. void
  123. Dict::addCharacter(Character *character)
  124. {
  125.     struct sCharCell *cell;
  126.  
  127.     cell = new sCharCell;
  128.     cell->elt = character;
  129.     cell->next = head;
  130.  
  131.     head = cell;
  132. }
  133.  
  134. Character *
  135. Dict::getCharacter(long id)
  136. {
  137.     struct sCharCell *cell;
  138.     
  139.     for(cell = head; cell; cell = cell->next)
  140.     {
  141.         if (id == cell->elt->getTagId()) return cell->elt;
  142.     }
  143.     return 0;
  144. }
  145.  
  146. void
  147. Dict::dictRewind()
  148. {
  149.     currentCell = head;
  150. }
  151.  
  152. Character *
  153. Dict::dictNextCharacter()
  154. {
  155.     if (currentCell) {
  156.         struct sCharCell *cell;
  157.  
  158.         cell = currentCell;
  159.         currentCell = currentCell->next;
  160.         return cell->elt;
  161.     } else {
  162.         return 0;
  163.     }
  164. }
  165.  
  166. #ifdef DUMP
  167. void
  168. Dict::dictSetUnsaved()
  169. {
  170.     struct sCharCell *cell;
  171.     
  172.     for(cell = head; cell; cell = cell->next)
  173.     {
  174.         cell->elt->saved = 0;
  175.     }
  176. }
  177. #endif
  178.